/*
 * 컴파일을 위해 올려 놓은 소스 입니다.
 * 서버에 반영하지 마시고 다른국가에 적용할 경우 서버에 있는 class 를 카피해서 사용하십시오.
 * 
 */
/*
 * Created on 2004. 9. 24.
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package com.pushmsg.OmaOtaConf;

import com.pushmsg.OmaOtaConf.OmaOtaObject.BOOTSTRAP;
import com.pushmsg.OmaOtaConf.OmaOtaObject.IMAP4;
import com.pushmsg.OmaOtaConf.OmaOtaObject.NAPDEF;
import com.pushmsg.OmaOtaConf.OmaOtaObject.POP3;
import com.pushmsg.OmaOtaConf.OmaOtaObject.SMTP;

/**
 * @author dgchun
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class OmaOtaEmail extends OmaOtaBody
{
	private SMTP smtp = null;
	private String inserver = null;
	private POP3 pop3 = null;
	private IMAP4 imap4 = null;
	private String profileName = null;
	public OmaOtaEmail()
	{
		super(0x06);		
	}
	
	public void setInserver(String in)
	{
		inserver = in;
	}
	
	public int getOtaType()
	{
		return super.getOtaType();
	}
	
	public SMTP getSmtp()
	{
		return smtp;
	}
	
	public POP3 getPop3()
	{
		return pop3;
	}
	
	public IMAP4 getImap4()
	{
		return imap4;
	}
	
	public void setProfileName(String name)
	{
		profileName = name;
	}
	//country = ger, operator=t-mobile, nettype=internet or wap
	public void setNapDef(String country, String operator, String bearer, String nettype)
	{
		bs = new BOOTSTRAP(profileName);
		//System.out.println("ddd = " + profileName);
		napDef = new NAPDEF(country, operator, "email", bearer, nettype);
		smtp =  new SMTP(napDef.getNapId());
		smtp.setProviderId(profileName);
		if(inserver.equals("pop3"))
		{
			pop3 = new POP3(napDef.getNapId());
			pop3.setProviderId(profileName);
		}
		else
		{
			imap4 = new IMAP4(napDef.getNapId());
			imap4.setProviderId(profileName);
		}
	}
	
	public void process()
	{
		data[length++] = (byte)0x03; //WBXML version 1.3
		data[length++] = (byte)0x0B; //Public Identifier for ��-//WAPFORUM//DTD PROV 1.0//EN��
		data[length++] = (byte)0x6A; //Character set UTF-8
		data[length++] = (byte)0x00; //String table length
		//<wap-provisioningdoc version="1.0">
		data[length++] = (byte)0xC5; 
		data[length++] = (byte)0x46; 
		data[length++] = (byte)0x01;
		
	    length += bs.getData(data, length);
		length += napDef.getData(data, length);		
		//length += smtp.getData(data, length);
		if(inserver.equals("pop3"))		{
			
			length += pop3.getData(data, length);
		}
		else
		{
			length += imap4.getData(data, length);
		}
		length += smtp.getData(data, length);
		data[length++] = (byte)0x01; //end of wap-provisioning
	}
			
}
